<?php


namespace app\api\model;


class Order extends BaseModel
{

    public function getSnapItemsAttr($value)
    {
        if(empty($value))
        {
            return null;
        }
        return json_decode($value);
    }

    public function getSnapAddressAttr($value)
    {
        if(empty($value))
        {
            return null;
        }
        return json_decode($value);
    }

    public static function getSimpleListByUser($user_id, $page=1, $size=15)
    {
        return self::where('user_id', '=', $user_id)
            ->order('create_time desc')
            ->paginate($size, true, ['page' => $page]);
    }

    public static function getAll($page=1, $size=15)
    {
        return self::order('create_time desc')
            ->paginate($size, true, ['page' => $page]);
    }
}